<template>
  <div class="content-block service-block">
    <div class="service-block">
      <div class="block-line"></div>
      <div class="sub-title">
        <div class="text">
          {{ item.title }}
        </div>
      </div>
      <div class="card">
        <div class="card-wrap" v-for="(detail, index) in item.columnsDetails" :key="index"
             @click="handleToPractice(detail)">
          <svg class="icon-third" aria-hidden="true">
            <use :xlink:href=detail.image></use>
          </svg>
          <div class="text-wrap">
            <div class="card-title">
              {{ detail.title }}
            </div>
            <div class="card-desc">
              {{ detail.description }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { useRouter } from "vue-router";

const router = useRouter();
const props = defineProps({
  item: {
    type: Object
  },
  repositoryId: {
    type: String
  }
});

function handleToPractice(record) {
  let query = {
    mode: record.mode
  };
  router.push({ path: `/practice/onlinePractice/${props.repositoryId}`, query: query });
}
</script>
<style lang="less" scoped>
.service-block {
  width: 100%;

  .service-block {
    width: 100%;
    margin: 0 auto;
    text-align: center;
  }

  .card {
    display: flex;
    justify-content: space-between;
    margin-top: -20px;
    padding: 16px 0;
  }

  .card-wrap {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    padding: 32px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 60px 0 rgba(0, 0, 0, .05);
  }

  .card-img {
    width: 150px;
    height: 150px;
    border-radius: 10px;
    object-fit: cover;
  }

  .card-wrap .text-wrap {
    text-align: center;
  }

  .card-title {
    margin: 14px 0;
    color: #31285d;
    font-size: 18px;
  }

  .card-desc {
    color: #646a73;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    line-height: 30px;
    letter-spacing: .34px;
  }

  .sub-title {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 36px 0;
    color: #31285d;
    font-size: 22px;
    line-height: 28px;
  }

  .sub-title:before {
    display: block;
    width: 36px;
    height: 6px;
    background: linear-gradient(270deg, rgba(160, 118, 248, 0), #6741ef);
    border-radius: 100px 0 0 100px;
    box-shadow: 0 0 0 0 rgba(0, 0, 0, .5);
    transform: rotate(180deg);
    opacity: .4;
    content: "";
  }

  .sub-title:after {
    display: block;
    width: 36px;
    height: 6px;
    background: linear-gradient(270deg, rgba(160, 118, 248, 0), #6741ef);
    border-radius: 100px 0 0 100px;
    box-shadow: 0 0 0 0 rgba(0, 0, 0, .5);
    opacity: .4;
    content: "";
  }

  .text {
    margin: 0 16px;
  }

  .card-wrap:not(:last-child) {
    margin-right: 34px;
  }

}
</style>
